import { defineStore } from "pinia";
import type { Tuser } from "@/models/user";
import { ref } from "vue";
import { get_user } from "@/api/userapi";

export const useUserInfo = defineStore("userinfo", () => {
    const userinfo = ref<Tuser>();


    (async () => {
        const res = await get_user({ id: localStorage.getItem("id") });
        if (res.code === 200) {
            userinfo.value = res.data;
        }
    })()
    return { userinfo }
}, { persist: true });
